var tab,h;
$(function(){
	h = HTR.pageHeight()-32;
	tab = $("#htr-tabs").ligerTab({
	      height: '99%',
	      changeHeightOnResize:true,
	      showSwitchInTab : false,
	      showSwitch: true
	});
	$('.l-tab-content').height(h);
	$('.l-tab-content-item').height(h);
	$('.l-tab-content-item').css('overflow-y','auto');
	var uploads = ['watermarkFile','appLogo','userLogo'],key;
	for(var i=0;i<uploads.length;i++){
		key = uploads[i];
		HTR.upload({
			  k:key,
		  	  pick:'#'+key+"Picker",
		  	  formData: {dir:'sysconfigs'},
		  	  accept: {extensions: 'gif,jpg,jpeg,bmp,png',mimeTypes: 'image/*'},
		  	  callback:function(f){
		  		  var json = HTR.toIndexJson(f);
		  		  if(json.status==1){
		  			 $('#'+this.k+'Msg').empty().hide();
		  			 $('#'+this.k+'Prevw').attr('src',HTR.conf.ROOT+'/'+json.savePath+json.name);
		  			 $('#'+this.k).val(json.savePath+json.name);
		  		  }
			  },
			  progress:function(rate){
				  $('#'+this.k+'Msg').show().html('已上传'+rate+"%");
			  }
		    });
	}
})
function edit(){
	if(!HTR.GRANT.XTPZ_02)return;
	var params = HTR.getParams('.ipt');
	var loading = HTR.msg('正在保存数据，请稍后...', {icon: 16,time:60000});
    $.post(HTR.U('index/sysconfigs/edit'),params,function(data,textStatus){
          layer.close(loading);
          var json = HTR.toIndexJson(data);
          if(json.status==1){
        	  HTR.msg(json.msg,{icon:1});
          }
   });
}
//编辑器
KindEditor.ready(function(K) {
editor1 = K.create('textarea[name="aboutUs"]', {
  height:'350px',
  width:'800px',
  uploadJson : HTR.conf.ROOT+'/index/sysconfigs/editorUpload',
  allowFileManager : false,
  allowImageUpload : true,
  filterMode: false,//是否开启过滤模式
  urlType:'domain',
  items:[
        'fontsize', 'forecolor', 'hilitecolor', '|', 'bold', 'italic', 'underline',
            'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
            'insertunorderedlist', '|', 'emoticons', 'image', 'link', 'source'
      ],
  afterBlur: function(){ this.sync(); }
});
});

$(function(){
	$('#watermarkColor').colpick({
	layout:'hex',
	submit:1,
	colorScheme:'dark',
	onChange:function(hsb,hex,rgb,el,bySetColor) {
		$(el).css('border-color','#'+hex);
	},
	onSubmit:function(hsb,hex,rgb,el,bySetColor){
		if(!bySetColor) $(el).val('#'+hex);
		$(el).colpickHide();
	}
	}).keyup(function(){
		$(this).colpickSetColor(this.value);
		$(this).colpickHide();
	});

});